var ValidationUtil = {
        
        isBlank: function(v){
            return  ((v == null) || (v.length == 0));
        },
        
        isNumber:function(v){
            return this.isBlank(v) || !(/^\d+(\.\d+)?$/.test(v));
        },
        
        isDigits:function(v){
            return this.isBlank(v) || /[^\d]/.test(v);
        },
        
        isEmail:function(v){
            return  /^[a-z0-9_\-\.]+@[a-z0-9_\-\.]+\.[a-z]{2,4}$/.test(v);
        },
        
        isDate:function(v){
            return this.isBlank(v) || !/Invalid|NaN/.test(new Date(v));
        },
        
        checkRangeValue : function(v,paramMin,paramMax){
            return !(v >= paramMin && v <= paramMax) ;
        },
        
        /*
        * new add to validate is letter and not blank
        */
        isLetter: function(v){
            return  this.isBlank(v) || !(/^[a-zA-Z]+$/.test(v));
        },
        
        isInteger: function(v){
            return  /^[1-9]+[0-9]*]*$/.test(v);
        },

        isUnique: function(){
            var result = false;
            var url = arguments[0];
            var value = arguments[1];
            var length = arguments.length;
            if(length == 2){
                url += "/v/" + value;
            }else if(length > 2){
                url += "/v/" + value + "/id/" + arguments[2];
            }
            $.ajax({
                type:"POST",
                async:false,
                url:url,
                dataType:"Html",
                success:function(responseText){
                    if(responseText == "1"){
                        result = true;
                    }
                }
            });
            return result;
        },
        
        isUniqueByPost: function(){
            var result = false;
            var url = arguments[0];
            var value = arguments[1];
            var length = arguments.length;
            if(length == 2){
                var data = {'v' : value};
            }else if(length > 2){
                var data = {'v' : value , 'id' : arguments[2]};
            }
            $.ajax({
                type:"POST",
                async:false,
                url:url,
                dataType:"Html",
                data : data,
                success:function(responseText){
                    if(responseText == "1"){
                        result = true;
                    }
                }
            });
            return result;
        },       

        showErrorMsg:function(){
            var id = arguments[0];
            var msgKey = arguments[1];
            var length = arguments.length;
            var message = $("#" + msgKey).val();
            if($("#" + id + "ErrorLabel")){
                $("#" + id + "ErrorLabel").html("&nbsp;");
            }
            if(length == 2){
                $("#" + id + "Error").html(message);
            }
            if(length > 2){
                message = message.replace(/%value%/, arguments[2]);
                if(arguments[3] && msgKey == "stringLengthTooLong"){
                     message = message.replace(/%max%/, arguments[3]);
                }
                $("#" + id + "Error").html(message);
            }
            
        },

        clearErrorMsg:function(id){
            $("#" + id + "ErrorLabel").html("");
            $("#" + id + "Error").html("");
        },

        showErrMsg:function(node,msg){
	    $(node).html(msg);
        },

	clearErrMsg:function(node){
	    $(node).empty();
	}

}